package com.cn.aam.checaiduo.ui.homepage.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cn.aam.checaiduo.AppData;
import com.cn.aam.checaiduo.R;
import com.cn.aam.checaiduo.base.adapter.BaseRecycerAdapter;
import com.cn.aam.checaiduo.base.adapter.holder.BaseRecyclerViewHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * monker on 2017/5/23.
 */

public class MeTypeAdapter extends BaseRecycerAdapter<MeTypeAdapter.MeType> {


    public MeTypeAdapter(Context mContext) {
        super(mContext);
        init();
    }


    private void init() {
        List<MeType> mMeTypes = new ArrayList<>();
        mMeTypes.add(new MeType("充值提现", R.drawable.ic_pay_withdrawals));
        mMeTypes.add(new MeType("预约投资", R.drawable.ic_auto_order));
        mMeTypes.add(new MeType(AppData.getContext().getString(R.string.voucher), R.drawable.ic_financial_voucher));
        mMeTypes.add(new MeType("新浪钱包", R.drawable.ic_xinlang));
        mMeTypes.add(new MeType("邀请有奖", R.drawable.ic_invite));
        mMeTypes.add(new MeType("投资记录", R.drawable.ic_invest_record));
        mMeTypes.add(new MeType("积分", R.drawable.ic_point));
        mMeTypes.add(new MeType("活动中心", R.drawable.ic_activity_center));
        mMeTypes.add(new MeType("签到", R.drawable.ic_sign_in));
        setDataToAdapter(mMeTypes);
    }

    @Override
    protected BaseRecyclerViewHolder getViewHolder(View picNewsView) {
        return new MeHolder(picNewsView);
    }

    @Override
    protected int getItemLayoutRes() {
        return R.layout.grid_metype_item;
    }

    @Override
    protected void ItemVIewChange(BaseRecyclerViewHolder recyclerholder, int position) {
        MeHolder holder = (MeHolder) recyclerholder;
        holder.icon.setImageResource(getItem(position).imgId);
        holder.name.setText(getItem(position).typeName);

    }

    class MeHolder extends BaseRecyclerViewHolder {
        @BindView(R.id.type_icon)
        ImageView icon;
        @BindView(R.id.type_name)
        TextView name;

        public MeHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }


    class MeType {
        public MeType(String typeName, int imgId) {
            this.imgId = imgId;
            this.typeName = typeName;
        }

        private String typeName;
        private int imgId;

    }
}

